package com.hmall.user.contorll;


import com.hmall.user.Address;
import com.hmall.user.server.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired(required = false)
    private AddressService addressService;
    /**
     * 根据id查找地址
     * @param
     * @return
     */
    @GetMapping("/uid/{userId}")
    public List<Address> selectById(@PathVariable("userId") Long userId){
      List<Address> addressList =  addressService.selectById(userId);
      return addressList;
    }
    //  根据addressId 查询Address
    @GetMapping("/{addressId}")
    public Address selectAddressById(@PathVariable("addressId") Long addressId){
        Address address = addressService.selectAddressById(addressId);
        return address;
    }
}
